package com.workcell.workdata.xthings.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum CommDataFormatEnum {

	NO_CHECKS("0","无校验"),
	ODD_CHECKS("1","奇校验"),
	EVEN_CHECK("2","偶校验");

	private final String code;
	private final String name;


	/**
	 * 根据值获取枚举
	 * @param code 类型
	 * @return 返回枚举
	 */
	public static CommDataFormatEnum getByCode(String code) {
		for (CommDataFormatEnum commDataFormatEnum : values()) {
			if (commDataFormatEnum.getCode().equals(code)) {
				//获取指定的枚举
				return commDataFormatEnum;
			}
		}
		return null;
	}
}
